package com.oocl.crm.command.receiver;

import com.oocl.crm.command.BaseReceiver;
import com.oocl.crm.exception.CrmException;
import com.oocl.crm.util.CommandParser;

public class ListReceiver extends BaseReceiver {

	public ListReceiver(String[] commandSplit) {
		super(commandSplit);
	}

	@Override
	public String action() throws CrmException {
		if (commandSplit.length < 2) {
			return "ID\tName\tSex\tBirthday\tAddress\tPhone\n" + service.findAllCustomers();
		}
		String[] info = CommandParser.parseCustomerInfo(commandSplit[1]);
		return "ID\tName\tSex\tBirthday\tAddress\tPhone\n"
				+ service.findCustomers(info[0], info[1], info[2], info[3], info[4], info[5]);
	}

}
